home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / urldecode.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.1 KB  |  45 lines

  1. <!-----------------------------------------------------------
  2.   This example illustrates use of the URLDecode function. 
  3.   ----------------------------------------------------------->
  4. <HTML>
  5. <HEAD>
  6. <TITLE>URLDecode</TITLE>
  7. </HEAD>
  8.  
  9. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  10. <BODY  bgcolor="#FFFFD5">
  11.  
  12. <H3>URLDecode</H3>
  13. <P>
  14. Here is an example of the URLDecode and URLEncodedFormat functions. 
  15. In this example, a string containing all ASCII character codes in 
  16. the range 1-255 is created. The string is then encoded and decoded. 
  17. The decoded value is compared with the original string to 
  18. demonstrate their equality.
  19. </P>
  20. <cfscript>
  21.     // Build string
  22.     s = "";
  23.     for (c = 1; c lte 256; c = c + 1)
  24.     {
  25.         s = s & chr(c);
  26.     }
  27.  
  28.     // Encode string and display result
  29.     enc = URLEncodedFormat(s);
  30.     writeOutput("Encoded string is: '#enc#'.<br>");
  31.  
  32.     // Decode and compare result with original
  33.     dec = URLDecode(enc);
  34.     if (dec neq s)
  35.     {
  36.         writeOutput("Decoded is not the same as encoded.");
  37.     }
  38.     else
  39.     {
  40.         writeOutput("All's well on the Western front.");
  41.     }
  42. </cfscript>
  43. </BODY>
  44. </HTML>       
  45.